<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>echarts</title>
    <style>
      .chart-container {
        width: 800px;
        height: 400px;
      }
    </style>
  </head>
  <body>
    <div class="chart-container"></div>
    <script src="./echarts.min.js"></script>
    <script>
      function randomData(num, min = 10, max = 100) {
        const data = [];
        for (let i = 0; i < num; i++) {
          data.push(Math.round(Math.random() * (max - min) + min));
        }
        return data;
      }

      const myEcharts = echarts.init(
        document.querySelector(".chart-container")
      );

      const data = [
        ["一月", 23, 33, "x", 11],
        ["二月", 27, 37, "y", 22],
        ["三月", 33, 23, "z", 33],
        ["四月", 38, 27],
        ["五月", 15, 25],
      ];

      const option = {
        xAxis: {
          type: "category",
        },
        yAxis: {},
        dataset: {
          source: data,
        },
        series: [
          {
            type: "line",
            encode: { x: 0, y: 1 },
          },
          {
            type: "bar",
            encode: { x: 0, y: 2 },
          },
          {
            type: "pie",
            radius: [0, 40], // 半径
            center: [650, 50], // 圆心点坐标
            encode: { itemName: 3, value: 4 },
          },
        ],
        // color: ["green", "yellow"],
      };
      myEcharts.setOption(option);
    </script>
  </body>
</html>
